package com.hwn.datax.domain;

import cn.hutool.core.date.DateUtil;
import com.hwn.datax.component.MySimpleIntegerProperty;
import javafx.beans.property.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

/**
 * @author wnhuang
 * @date 2024/6/3 23:17
 */
@Data
@EqualsAndHashCode
public class DataxJobRunLog {
    private String uuid;
    private Long jobId;
    private String jobName;
    private String jobPath;
    private String shellCommand;
    private String serverName;
    private String serverIp;
    private String logPath;
    private Integer serverId;
    private String startTime;
    ;
    /**
     * 0: 执行中 1: 执行成功 2: 执行失败
     */
    private MySimpleIntegerProperty status = new MySimpleIntegerProperty();

    /**
     * 执行日志
     */
    private SimpleStringProperty logContent = new SimpleStringProperty("");

    private final SimpleIntegerProperty total = new SimpleIntegerProperty();
    private Integer current;
    private final SimpleDoubleProperty percentage = new SimpleDoubleProperty();
    private final SimpleLongProperty totalRecords = new SimpleLongProperty();
    private Integer result;

    private SimpleStringProperty endTime = new SimpleStringProperty();
    private Boolean hasNext;
    private String nextUuid;


    public void setTotal(int total) {
        this.total.set(total);
    }

    public int getTotal() {
        return total.get();
    }

    public IntegerProperty totalProperty() {
        return total;
    }

    public void setPercentage(double percentage) {
        this.percentage.set(percentage);
    }


    public double getPercentage() {
        return percentage.get();
    }


    public DoubleProperty percentageProperty() {
        return percentage;
    }


    public void setStatus(int status) {
        this.status.set(status);
    }

    public int getStatus() {
        return status.get();
    }

    public MySimpleIntegerProperty statusProperty() {
        return status;
    }

    public void setLogContent(String logContent) {
        this.logContent.set(logContent);
    }


    public String getLogContent() {
        return logContent.get();
    }


    public StringProperty logContentProperty() {

        return logContent;
    }

    public void setTotalRecords(Long totalRecords) {
        this.totalRecords.set(totalRecords);
    }

    public Long getTotalRecords() {

        return totalRecords.get();
    }

    public LongProperty totalRecordsProperty() {
        return totalRecords;
    }

    public void setEndTime(Date endTime) {
        this.endTime.set(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
    }

    public String getEndTime() {
        return this.endTime.get();
    }

    public StringProperty endTimeProperty() {
        return this.endTime;
    }


    public void setStartTime(Date endTime) {
        this.startTime = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss");
    }

}
